<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" %>
<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page import="java.sql.*" %> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>测试到MySQL数据链接</title>
</head>
<body>
	<%
    String driverName="com.mysql.jdbc.Driver"; 
	//数据库用户名 
	String userName="bradden"; 
	//密码 
	String userPasswd="466123"; 
	//数据库名 
	String dbName="roombook";
	String DBUrl = "jdbc:mysql://localhost/"+dbName;
	try {
		Class.forName(driverName).newInstance();
		//Class.forName("org.gjt.mm.mysql.Driver").newInstance();
		Connection conn = DriverManager.getConnection(DBUrl,userName,userPasswd);
		out.print("数据库操作成功，恭喜你"); 
		//关闭数据库
		conn.close();
	}
		catch (Exception e) {
		e.printStackTrace();
	}
	%>
</body>
</html>